
// import oimo.common.Vec3;
// import oimo.dynamics.rigidbody.RigidBody;

import { JointConfig } from "./JointConfig";
import { Vec3 } from "../../../common/Vec3";
import { TranslationalLimitMotor } from "./TranslationalLimitMotor";
import { SpringDamper } from "./SpringDamper";
import { RigidBody } from "../../rigidbody/RigidBody";

/**
 * A prismatic joint config is used for constructions of prismatic joints.
 */
export class PrismaticJointConfig extends JointConfig {
	/**
	 * The first body's local constraint axis.
	 */
	 localAxis1:Vec3;

	/**
	 * The second body's local constraint axis.
	 */
	 localAxis2:Vec3;

	/**
	 * The translational limit and motor along the constraint axis of the joint.
	 */
	 limitMotor:TranslationalLimitMotor;

	/**
	 * The translational spring and damper along the constraint axis of the joint.
	 */
	 springDamper:SpringDamper;

	/**
	 * Default constructor.
	 */
	constructor() {
		super();
		this.localAxis1 = new Vec3(1, 0, 0);
		this.localAxis2 = new Vec3(1, 0, 0);
		this.limitMotor = new TranslationalLimitMotor();
		this.springDamper = new SpringDamper();
	}

	/**
	 * Sets rigid bodies, local anchors from the world anchor `worldAnchor`, local axes
	 * from the world axis `worldAxis`, and returns `this`.
	 */
	public init(rigidBody1:RigidBody, rigidBody2:RigidBody, worldAnchor:Vec3, worldAxis:Vec3):PrismaticJointConfig {
		this._init(rigidBody1, rigidBody2, worldAnchor);
		rigidBody1.getLocalVectorTo(worldAxis, this.localAxis1);
		rigidBody2.getLocalVectorTo(worldAxis, this.localAxis2);
		return this;
	}

}
